﻿using EOrm;
using System;
using System.IO;

namespace LeanApp.Bll
{
    /// <summary>
    /// 控制重写
    /// </summary>
    public class ConfigOverwrite
    {
        /// <summary>
        /// 重写配置
        /// </summary>
        public static void OverwriteConfig()
        {
            string _defaultDbFilePath = AppDomain.CurrentDomain.BaseDirectory + "data.db";
            ConStr conStr = EOrmCon.GetConStr();
            if (!File.Exists(conStr.FilePath))
            {
                if (!File.Exists(_defaultDbFilePath))
                {
                    throw new FileNotFoundException("数据文件不存在，请联系开发商", _defaultDbFilePath);
                }
                conStr.FilePath = _defaultDbFilePath;
                EOrmCon.SetConStr(conStr);
            }
        }
    }
}
